# set colors
#set -g default-terminal "screen-256color"

set -s default-terminal screen-256color
set -sa terminal-overrides ",*-256color:Tc"
setw -g xterm-keys on
# set the base index for windows to 1
set -g base-index 1

# set the base index for panes to 1
set -g pane-base-index 1

# set prefix
set-option -g prefix C-a
unbind C-b
bind C-a send-prefix

# split windows with with Ctrl + a | and _
unbind %
bind | split-window -h -c "#{pane_current_path}"
bind _ split-window -v -c "#{pane_current_path}"

setw -g mode-keys vi

# set window list
setw -g window-status-fg green
setw -g window-status-bg default
setw -g window-status-attr dim

# Set status bar
set -g status-bg colour21
set -g status-fg colour06
set -g status-left '#[fg=green]#H: #[fg=colour08]#S #[fg=green]|'
set -g status-left-length 300

# set right status bar content
set -g status-right '#[fg=green] | #[fg=colour08]#(date +"%A %F %R")'

set -g status-interval 60

# Highlight active window
set-window-option -g window-status-current-fg colour21
set-window-option -g window-status-current-bg colour18

# Agressive resize
setw -g aggressive-resize on

# Activity Monitoring
setw -g monitor-activity on
set -g visual-activity on

# center the window list
set -g status-justify centre

bind P pipe-pane -o "cat >>~/#W.log" \; display "Toggled logging to ~/#W.log"

# moving between panes
bind h select-pane -L
bind j select-pane -D
bind k select-pane -U
bind l select-pane -R

bind -n S-F1 select-pane -t 1
bind -n S-F2 select-pane -t 2
bind -n S-F3 select-pane -t 3
bind -n S-F4 select-pane -t 4
bind -n S-F5 select-pane -t 5
bind -n S-F6 select-pane -t 6
bind -n S-F7 select-pane -t 7
bind -n S-F8 select-pane -t 8

bind -n M-1 select-window -t 1
bind -n M-2 select-window -t 2
bind -n M-3 select-window -t 3
bind -n M-4 select-window -t 4
bind -n M-5 select-window -t 5
bind -n M-6 select-window -t 6
bind -n M-7 select-window -t 7
bind -n M-8 select-window -t 8
bind -n M-9 select-window -t 9

bind -r C-h select-window -t :-
bind -r C-l select-window -t :+

# Pane resizing
bind -r H resize-pane -L 5
bind -r J resize-pane -D 5
bind -r K resize-pane -U 5
bind -r L resize-pane -R 5

bind O kill-pane -a

if-shell "[ -f ~/.osx-paste-fix.conf ]" 'source ~/.osx-paste-fix.conf'

set-option -g history-limit 4000

# this is set a the session level, not when you attach
set-option -g update-environment 'ITERM_PROFILE COLORFGBG'

bind C new-session
# 
# Fixing bug requring escape to be double pressed. https://github.com/tmux/tmux/issues/131
set -g escape-time 10
